﻿using System;
using System.Collections.Generic;
 using UnityEngine;
using System.Text;

 
   public abstract class ISoldier:ICharacter
   {
       protected SoldierFSMSystem mFSMSystem;

       private void MakeFSM()
       { 
          //初始化状态机 构建战士有限状态机
           mFSMSystem = new SoldierFSMSystem();
           SoldierIdleState idleState = new SoldierIdleState(mFSMSystem,this);
           idleState.AddTransition(SoldierTransition.SeeEnemy,SoldierStateID.Chase);
           SoldierChaseState chaseState = new SoldierChaseState(mFSMSystem,this);
           chaseState.AddTransition(SoldierTransition.NoEnemy,SoldierStateID.Idle);
           chaseState.AddTransition(SoldierTransition.CanAttack, SoldierStateID.Attack);
           SoldierAttckState attckState = new SoldierAttckState(mFSMSystem,this);
           attckState.AddTransition(SoldierTransition.NoEnemy, SoldierStateID.Idle);
           attckState.AddTransition(SoldierTransition.SeeEnemy, SoldierStateID.Chase);

           mFSMSystem.AddState(idleState,chaseState, attckState);
           
       }

       public ISoldier():base()
       {
           MakeFSM();
       }

       public override void UpdateFSMAI(List<ICharacter> targets)
       {
           mFSMSystem.currentState.Reason(targets);
        mFSMSystem.currentState.Act(targets);

       }
    public override void UnderAttack(int damage)
    {
        base.UnderAttack(damage);
        if (mAttr.currentHP <=0)
        {
            //战士既要播放声音 又要播放特效
            PlaySound();
            PlayEffect();
            Killed();
        }
    }

       protected abstract void PlaySound();
       protected abstract void PlayEffect();

      

   }
 
